package com.fearless.crm.workbench.service.impl;

import com.fearless.crm.vo.CustomerRemarkVo;
import com.fearless.crm.workbench.dao.CustomerRemarkDao;
import com.fearless.crm.workbench.entity.CustomerRemark;
import com.fearless.crm.workbench.service.CustomerRemarkService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;

@Service
public class CustomerRemarkServiceImpl implements CustomerRemarkService {

    @Resource
    private CustomerRemarkDao customerRemarkDao;


//展现客户相关的备注列表
    public List<CustomerRemarkVo> getRemarkListByCustomerId(String id) {
        List<CustomerRemarkVo> customerRemarkVoList=customerRemarkDao.getRemarkByCustomerId(id);

        return customerRemarkVoList;
    }

//新增客户备注
    public Map addCustomerRemark(CustomerRemark customerRemark) {
        boolean flag=true;
        int count=customerRemarkDao.addCustomerRemark(customerRemark);
        CustomerRemark customerRemark1=customerRemarkDao.addCustomerRemarkQuery(customerRemark);

        if(count!=1){
            flag=false;
        }
        Map map=new Hashtable();
        map.put("success",flag);
        map.put("cr",customerRemark1);
        return map;
    }

//执行删除客户备注的操作
    public boolean deleteCustomerRemark(String id) {
        boolean flag=true;

        int count=customerRemarkDao.deleteCustomerRemark(id);

        if(count!=1){
            flag=false;
        }

        return flag;
    }


//执行铺垫修改客户备注的模态窗口
    public CustomerRemark getCustomerRemark(String id) {
       CustomerRemark customerRemark= customerRemarkDao.getCustomerRemark(id);
        return customerRemark;
    }

//执行修改客户备注的操作
    public boolean updateCustomerRemark(CustomerRemark customerRemark) {
        boolean flag=true;

       int count= customerRemarkDao.updateCustomerRemark(customerRemark);

       if(count!=1){
           flag=false;
       }

        return flag;
    }




}
